import matplotlib.pyplot as plt
import numpy as np




if __name__ == '__main__':

    stage = 'ONet'
    ROC_files = {'pytorch-wider':['r','./results/ROC-files/pytorch_O_ROC.txt','pt-wider(0.6,0.6,0.01,min-face=24)'],
                 'pytorch-heils-landmarks': ['orange', './results/ROC-files/pytorch_L_ROC.txt', 'pt-heils-lds(0.6,0.6,0.001,min-face=24)'],
                 'mxnet':['b','./results/ROC-files/mxnet_O_ROC.txt','mxnet(0.6,0.15,0.05,min-face=24)'],
                 'caffe': ['y', './results/ROC-files/caffe_O_ROC.txt','caffe(0.6,0.6,0.01,min-face=24)'],
                 'tensorflow':['g','./results/ROC-files/tf_O_ROC.txt', 'tensorflow(0.6,0.35,0.01,min-face=24)']
                 }

    # with plt.style.context('ggplot'):
    plt.figure("DiscRoc")
    plt.title(stage + " Evalution")
    plt.xlabel("False Positive")
    plt.ylabel("True Positive Rate")
    plt.xticks(np.arange(0, 2000, 100))
    plt.yticks(np.arange(0, 1.0, 0.05))
    plt.grid(linestyle='--')
    for k, v in ROC_files.items():
        DiscROCfile = open(v[1],'r')
        tpr = []
        fp = []
        for point in DiscROCfile:
            data = point.split()
            tpr.append(float(data[0]))
            fp.append(int(data[1]))

        tpr = tpr[::-1]
        fp = fp[::-1]
        plt.plot(fp, tpr,v[0], label = v[2])

        plt.legend(loc=4, borderaxespad=0.)

    #
    # listX=[]
    # listY=[]
    # for point in ContROCfile:
    #     xy = point.split()
    #     if (float(xy[1]) < 3000):
    #         listX.append(int(xy[1])) # / float(2844))
    #         listY.append(xy[0])
    # plt.plot(listX,listY,'g')
    #
    plt.show()